package com.hkbigdata.transform;

import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

/**
 * @author liuanbo
 * @creat 2024-04-11-10:08
 * @see 2194550857@qq.com
 */
public class Flink02_TransForm_FlatMap_Anonymous {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        SingleOutputStreamOperator<Integer> map = env.fromElements(1, 2, 3, 4, 5, 6)
                .flatMap((Integer value, Collector<Integer> out)->{
                    out.collect(value*value);
//                    out.collect(value*value*value);
                }).returns(Types.INT);
        map.print();

        env.execute();

    }
}
